<template>
  <view class="infoList">
    <web-view :src="pageUrl" @message="receiveMessage" />
  </view>
</template>
<script>
import { webviewBaseUrl } from '../../../config/api';
export default {
  data() {
    return {
      pageUrl: `${webviewBaseUrl}/infoList`
    };
  },
  onLoad() {
    uni.setNavigationBarTitle({ title: '信息维护' });
    // #ifdef H5
    window.addEventListener('message', this.receiveMessage);
    // #endif
  },
  onShow() {
    let page = uni.getStorageSync('page');
    if (page !== 'infoList') {
      uni.setStorageSync('page', 'infoList');
      uni.reLaunch({ url: '/pages/home/components/infoList' });
    }
  },
  methods: {
    receiveMessage(event) {
      // #ifdef APP-PLUS
      if (event.detail.data) {
        uni.navigateTo({ url: event.detail.data[0] });
      }
      // #endif
      // #ifdef H5
      if (event.data.data) {
        uni.navigateTo({ url: event.data.data.arg });
      }
      // #endif
    }
  }
};
</script>
<style lang="scss" scoped>
.infoList {
  height: 100%;
  width: 100%;
  background: #f2f5f8;
}
</style>
